package org.jeecg.modules.yusuan.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.yusuan.entity.CaiwuBiaozhun;
import org.jeecg.modules.yusuan.entity.CaiwuZhijie;
import org.jeecg.modules.yusuan.entity.NianDuHuiZong;

import java.util.List;
import java.util.Map;

/**
 * @Description: caiwu_yusuan
 * @Author: jeecg-boot
 * @Date:   2020-06-15
 * @Version: V1.0
 */
public interface CaiwuBiaozhunMapper extends BaseMapper<CaiwuBiaozhun> {

    List<CaiwuBiaozhun> listData(@Param("deptId") String deptId,@Param("deptCode")String deptCode, @Param("categoryPid") String categoryPid,@Param("effective")Integer effective,@Param("version")Integer version);

    List<CaiwuBiaozhun> zhibiaolistData(@Param("deptId") String deptId,@Param("deptCode")String deptCode, @Param("categoryPid") String categoryPid,@Param("effective")Integer effective,@Param("version")Integer version);

    @Select("select xiafashu shenheshu,category_id as categoryId,(xiafashu - shenheshu) as jz from caiwu_biaozhun y,sys_category c where c.id = y.category_id and c.sys_org_code = 'A01' and dept_id = #{deptId}")
    List<Map> shenheshu(@Param("deptId") String deptId);

    List<Map> duixiaShenheshu(@Param("deptList") List<SysDepart> deptList);

    @Select({"<script>",
            "select max(version) from caiwu_biaozhun where dept_id = #{deptId} ",
            "<when test='effective!=null'>",
            "AND effective = #{effective}",
            "</when>",
            "</script>"})
    Integer getMaxVersion(@Param("effective") Integer effective, @Param("deptId") String deptId);
}
